package org.dolphin.entity.promo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
import org.dolphin.base.constant.DatabaseAttribute;
import org.dolphin.entity.interceptor.Auditable;
import org.dolphin.entity.security.User;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "MS_SEASONAL_PROMOTION", uniqueConstraints = {@UniqueConstraint(columnNames = {"CODE"}, name = "UQ_MS_SEASONAL_PROMOTION_CODE")})
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class SeasonalPromotion implements Serializable, Auditable {
  private static final long serialVersionUID = 1388601903181330697L;
  private String id;
  private String code;
  private String description;
  private Boolean active;
  private Date startDate;
  private Date endDate;
  private Long version;
  private Date createdDate;
  private Date updatedDate;
  private User createdBy;
  private User updatedBy;
  private BigDecimal promotionPrice;

  @Column(name = "ACTIVE", nullable = false)
  public Boolean getActive() {
    return active;
  }

  @Column(name = "CODE", length = 200, nullable = false)
  public String getCode() {
    return code;
  }

  @Override
  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "CREATED_BY", nullable = false)
  @ForeignKey(name = "FK_MS_SEASONAL_PROMOTION_CREATED_BY")
  public User getCreatedBy() {
    return createdBy;
  }

  @Override
  @Temporal(TemporalType.TIMESTAMP)
  @Column(name = "CREATED_DATE", nullable = false)
  public Date getCreatedDate() {
    return createdDate;
  }

  @Column(name = "DESCRIPTION", nullable = false, length = 500)
  public String getDescription() {
    return description;
  }

  @Temporal(TemporalType.DATE)
  @Column(name = "END_DATE", nullable = false)
  public Date getEndDate() {
    return endDate;
  }

  @Id
  @GeneratedValue(generator = "uuid2")
  @GenericGenerator(name = "uuid2", strategy = "org.dolphin.base.id.generator.CustomUUIDGenerator")
  @Column(name = "ID", nullable = false, length = DatabaseAttribute.ID_LENGTH)
  public String getId() {
    return id;
  }

  @Column(name = "PROMOTION_PRICE", nullable = false, precision = DatabaseAttribute.MONEY_PRECISION, scale = DatabaseAttribute.MONEY_SCALE)
  public BigDecimal getPromotionPrice() {
    return promotionPrice;
  }

  @Temporal(TemporalType.DATE)
  @Column(name = "START_DATE", nullable = false)
  public Date getStartDate() {
    return startDate;
  }

  @Override
  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "UPDATED_BY", nullable = true)
  @ForeignKey(name = "FK_MS_SEASONAL_PROMOTION_UPDATED_BY")
  public User getUpdatedBy() {
    return updatedBy;
  }

  @Override
  @Temporal(TemporalType.TIMESTAMP)
  @Column(name = "UPDATED_DATE", nullable = true)
  public Date getUpdatedDate() {
    return updatedDate;
  }

  @Version
  @Column(name = "VERSION_NO", nullable = false)
  public Long getVersion() {
    return version;
  }

  public void setActive(Boolean active) {
    this.active = active;
  }

  public void setCode(String code) {
    this.code = code;
  }

  @Override
  public void setCreatedBy(User createdBy) {
    this.createdBy = createdBy;
  }

  @Override
  public void setCreatedDate(Date createdDate) {
    this.createdDate = createdDate;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public void setEndDate(Date endDate) {
    this.endDate = endDate;
  }

  public void setId(String id) {
    this.id = id;
  }

  public void setPromotionPrice(BigDecimal promotionPrice) {
    this.promotionPrice = promotionPrice;
  }

  public void setStartDate(Date startDate) {
    this.startDate = startDate;
  }

  @Override
  public void setUpdatedBy(User updatedBy) {
    this.updatedBy = updatedBy;
  }

  @Override
  public void setUpdatedDate(Date updatedDate) {
    this.updatedDate = updatedDate;
  }

  public void setVersion(Long version) {
    this.version = version;
  }
}
